import { RouteRecordRaw } from 'vue-router';
import { Layout } from '@/router/constant';
import { DashboardOutlined } from '@vicons/antd';
import { renderIcon } from '@/utils/index';

const routeName = 'SystemSetting';

/**
 * @param name 路由名称, 必须设置,且不能重名
 * @param meta 路由元信息（路由附带扩展信息）
 * @param redirect 重定向地址, 访问这个路由时,自定进行重定向
 * @param meta.disabled 禁用整个菜单
 * @param meta.title 菜单名称
 * @param meta.icon 菜单图标
 * @param meta.keepAlive 缓存该路由
 * @param meta.sort 排序越小越排前
 * */
const routes: Array<RouteRecordRaw> = [
  {
    path: '/SystemSetting',
    name: routeName,
    redirect: '/SystemSetting/userList',
    component: Layout,
    meta: {
      title: '系统设置',
      icon: renderIcon(DashboardOutlined),
      sort: 3,
    },
    children: [
      {
        path: 'userList',
        name: 'SystemSettingUserList',
        meta: {
          title: '用户管理',
          keepAlive: true,
        },
        component: () => import('@/views/SystemSetting/userList/index.vue'),
      },
      {
        path: 'organization',
        name: 'organizationManagement',
        meta: {
          title: '用户组管理',
          keepAlive: true,
        },
        component: () => import('@/views/SystemSetting/organizationManagement/index.vue'),
      },
      {
        path: 'roleManagement',
        name: 'roleManagement',
        meta: {
          keepAlive: true,
          title: '角色管理',
        },
        component: () => import('@/views/SystemSetting/roleManagement/index.vue'),
      },
      {
        path: 'roleManagement/addRole/:roleGroupId?',
        name: 'addRole',
        meta: {
          title: '角色管理',
          activeMenu:'roleManagement',
          hidden: true,
          keepAlive: true,
        },
        component: () => import('@/views/SystemSetting/roleManagement/addRole.vue'),
      },
      {
        path: 'MenuManagement',
        name: 'MenuManagement',
        meta: {
          title: '菜单管理',
          keepAlive: true,
        },
        component: () => import('@/views/SystemSetting/MenuManagement/index.vue'),
      },
      {
        path: 'MenuManagement/addMenu/:parentId?/:name?',
        name: 'addMenu',
        meta: {
          title: '新增菜单',
          activeMenu:'MenuManagement',
          hidden: true,
          keepAlive: true,
        },
        component: () => import('@/views/SystemSetting/MenuManagement/addMenu.vue'),
      },
      {
        path: 'MenuManagement/editMenu/:name?/:formValue?',
        name: 'editMenu',
        meta: {
          title: '编辑菜单',
          activeMenu:'MenuManagement',
          hidden: true,
          keepAlive: true,
        },
        component: () => import('@/views/SystemSetting/MenuManagement/editMenu.vue'),
      },
      // {
      //   path: 'MenuManagement/childrenaddMenu/:id/:parentId?',
      //   name: 'childrenaddMenu',
      //   meta: {
      //     title: '新增菜单',
      //     activeMenu:'MenuManagement',
      //     hidden: true,
      //     keepAlive: true,
      //   },
      //   component: () => import('@/views/SystemSetting/MenuManagement/childrenaddMenu.vue'),
      // },
      {
        path: 'jurisdiction',
        name: 'jurisdictionManagement',
        meta: {
          title: '权限管理',
          keepAlive: true,
        },
        component: () => import('@/views/SystemSetting/jurisdictionManagement/index.vue'),
      },
      {
        path: 'authority',
        name: 'authorityManagement',
        meta: {
          title: '日志管理',
          keepAlive: true,
        },
        component: () => import('@/views/SystemSetting/authorityManagement/index.vue'),
      },
    ],
  },
];

export default routes;
